<?php
require_once(LIB.'database.php');
class DatabaseObject{
	//protected static $table_name = 'sss';
	
	public static function find_by_sql($sql = ""){
		//Useful for instances where custom queries would
		//need to be executed 
		global $database;
		$result = $database->query($sql);
		$obj_array = array();
		while ($row = $database->fetch_array($result)){
			
			//static allows for late static binding - The late static 
			//binding allows for you to refer to the class that called 
			//the method and not the current class which would otherwise 
			//be referred to as "self"
			$obj_array[] = static::instantiate($row);
		}
		return $obj_array;
		
	}
	
	public static function find_all(){
			return static ::find_by_sql("Select * from ".static::$table_name);
		}

}
?>